from tortoise.models import Model
from tortoise import fields
from enum import Enum

# 登录表
class RoleEnum(str, Enum):
    student = "student"
    teacher = "teacher"
    admin = "admin"
class Login(Model):
    id = fields.IntField(pk=True)
    username = fields.CharField(max_length=255, unique=True)
    password = fields.CharField(max_length=255)
    role = fields.CharEnumField(RoleEnum, default=RoleEnum.student)

# 个人中心表
class User(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=255, null=True)
    age = fields.IntField(null=True)
    sex = fields.CharField(max_length=255, null=True)
    phone = fields.CharField(max_length=255, null=True)
    email = fields.CharField(max_length=255, null=True)
    extral_1 = fields.CharField(max_length=255, null=True) #课程独有ID
    extral_2 = fields.CharField(max_length=255, null=True)
    extral_3 = fields.CharField(max_length=255, null=True)
    login_id = fields.ForeignKeyField('models.Login', related_name='user')

# 课程表
class Course(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=255, null=True)
    video = fields.CharField(max_length=255, null=True)
    picture = fields.CharField(max_length=255, null=True)
    content = fields.CharField(max_length=255, null=True)
    status = fields.CharField(max_length=255, null=True)
    extral_1 = fields.CharField(max_length=255, null=True) #课程独有ID
    extral_2 = fields.CharField(max_length=255, null=True)
    extral_3 = fields.CharField(max_length=255, null=True)
    user_id = fields.ForeignKeyField('models.User', related_name='course')

# 处理课程添加信息
class Course_Copy(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=255, null=True)
    video = fields.CharField(max_length=255, null=True)
    picture = fields.CharField(max_length=255, null=True)
    content = fields.CharField(max_length=255, null=True)
    status = fields.CharField(max_length=255, null=True)
    extral_1 = fields.CharField(max_length=255, null=True) #课程独有ID
    extral_2 = fields.CharField(max_length=255, null=True)
    extral_3 = fields.CharField(max_length=255, null=True)
    user_id_stu = fields.ForeignKeyField('models.User', related_name='course_copy_stu')
    user_id_tea = fields.IntField(null=True)
# 评论表
class Comment(Model):
    id = fields.IntField(pk=True)
    content = fields.CharField(max_length=255, null=True)
    send_time = fields.CharField(max_length=255, null=True)
    extral_1 = fields.CharField(max_length=255, null=True)
    extral_2 = fields.CharField(max_length=255, null=True)
    extral_3 = fields.CharField(max_length=255, null=True)
    user_id = fields.ForeignKeyField('models.User', related_name='comment')

# 讨论表
class Question(Model):
    id = fields.IntField(pk=True)
    content = fields.CharField(max_length=255, null=True)
    send_time = fields.CharField(max_length=255, null=True)
    extral_1 = fields.CharField(max_length=255, null=True)
    extral_2 = fields.CharField(max_length=255, null=True)
    extral_3 = fields.CharField(max_length=255, null=True)
    user_id = fields.ForeignKeyField('models.User', related_name='question')
